1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module pango.PgAttribute; 26 27 private import glib.ErrorG; 28 private import glib.GException; 29 private import glib.SimpleXML; 30 private import glib.Str; 31 private import glib.c.functions; 32 private import gobject.ObjectG; 33 private import pango.PgAttributeFontDesc; 34 private import pango.PgAttributeLanguage; 35 private import pango.PgAttributeList; 36 private import pango.PgAttributeShape; 37 private import pango.PgAttributeSize; 38 private import pango.c.functions; 39 public import pango.c.types; 40 41 42 /** 43 * The `PangoAttribute` structure represents the common portions of all 44 * attributes. 45 * 46 * Particular types of attributes include this structure as their initial 47 * portion. The common portion of the attribute holds the range to which 48 * the value in the type-specific part of the attribute applies and should 49 * be initialized using [method@Pango.Attribute.init]. By default, an attribute 50 * will have an all-inclusive range of [0,%G_MAXUINT]. 51 */ 52 public class PgAttribute 53 { 54 /** the main Gtk struct */ 55 protected PangoAttribute* pangoAttribute; 56 protected bool ownedRef; 57 58 /** Get the main Gtk struct */ 59 public PangoAttribute* getPgAttributeStruct(bool transferOwnership = false) 60 { 61 if (transferOwnership) 62 ownedRef = false; 63 return pangoAttribute; 64 } 65 66 /** the main Gtk struct as a void* */ 67 protected void* getStruct() 68 { 69 return cast(void*)pangoAttribute; 70 } 71 72 /** 73 * Sets our main struct and passes it to the parent class. 74 */ 75 public this (PangoAttribute* pangoAttribute, bool ownedRef = false) 76 { 77 this.pangoAttribute = pangoAttribute; 78 this.ownedRef = ownedRef; 79 } 80 81 82 /** */ 83 public static GType getType() 84 { 85 return pango_attribute_get_type(); 86 } 87 88 /** 89 * Returns the attribute cast to `PangoAttrColor`. 90 * 91 * This is mainly useful for language bindings. 92 * 93 * Returns: The attribute as `PangoAttrColor`, 94 * or %NULL if it's not a color attribute 95 * 96 * Since: 1.50 97 */ 98 public PangoAttrColor* asColor() 99 { 100 return pango_attribute_as_color(pangoAttribute); 101 } 102 103 /** 104 * Returns the attribute cast to `PangoAttrFloat`. 105 * 106 * This is mainly useful for language bindings. 107 * 108 * Returns: The attribute as `PangoAttrFloat`, 109 * or %NULL if it's not a floating point attribute 110 * 111 * Since: 1.50 112 */ 113 public PangoAttrFloat* asFloat() 114 { 115 return pango_attribute_as_float(pangoAttribute); 116 } 117 118 /** 119 * Returns the attribute cast to `PangoAttrFontDesc`. 120 * 121 * This is mainly useful for language bindings. 122 * 123 * Returns: The attribute as `PangoAttrFontDesc`, 124 * or %NULL if it's not a font description attribute 125 * 126 * Since: 1.50 127 */ 128 public PgAttributeFontDesc asFontDesc() 129 { 130 auto __p = pango_attribute_as_font_desc(pangoAttribute); 131 132 if(__p is null) 133 { 134 return null; 135 } 136 137 return ObjectG.getDObject!(PgAttributeFontDesc)(cast(PangoAttrFontDesc*) __p); 138 } 139 140 /** 141 * Returns the attribute cast to `PangoAttrFontFeatures`. 142 * 143 * This is mainly useful for language bindings. 144 * 145 * Returns: The attribute as `PangoAttrFontFeatures`, 146 * or %NULL if it's not a font features attribute 147 * 148 * Since: 1.50 149 */ 150 public PangoAttrFontFeatures* asFontFeatures() 151 { 152 return pango_attribute_as_font_features(pangoAttribute); 153 } 154 155 /** 156 * Returns the attribute cast to `PangoAttrInt`. 157 * 158 * This is mainly useful for language bindings. 159 * 160 * Returns: The attribute as `PangoAttrInt`, 161 * or %NULL if it's not an integer attribute 162 * 163 * Since: 1.50 164 */ 165 public PangoAttrInt* asInt() 166 { 167 return pango_attribute_as_int(pangoAttribute); 168 } 169 170 /** 171 * Returns the attribute cast to `PangoAttrLanguage`. 172 * 173 * This is mainly useful for language bindings. 174 * 175 * Returns: The attribute as `PangoAttrLanguage`, 176 * or %NULL if it's not a language attribute 177 * 178 * Since: 1.50 179 */ 180 public PgAttributeLanguage asLanguage() 181 { 182 auto __p = pango_attribute_as_language(pangoAttribute); 183 184 if(__p is null) 185 { 186 return null; 187 } 188 189 return ObjectG.getDObject!(PgAttributeLanguage)(cast(PangoAttrLanguage*) __p); 190 } 191 192 /** 193 * Returns the attribute cast to `PangoAttrShape`. 194 * 195 * This is mainly useful for language bindings. 196 * 197 * Returns: The attribute as `PangoAttrShape`, 198 * or %NULL if it's not a shape attribute 199 * 200 * Since: 1.50 201 */ 202 public PgAttributeShape asShape() 203 { 204 auto __p = pango_attribute_as_shape(pangoAttribute); 205 206 if(__p is null) 207 { 208 return null; 209 } 210 211 return ObjectG.getDObject!(PgAttributeShape)(cast(PangoAttrShape*) __p); 212 } 213 214 /** 215 * Returns the attribute cast to `PangoAttrSize`. 216 * 217 * This is mainly useful for language bindings. 218 * 219 * Returns: The attribute as `PangoAttrSize`, 220 * or NULL if it's not a size attribute 221 * 222 * Since: 1.50 223 */ 224 public PgAttributeSize asSize() 225 { 226 auto __p = pango_attribute_as_size(pangoAttribute); 227 228 if(__p is null) 229 { 230 return null; 231 } 232 233 return ObjectG.getDObject!(PgAttributeSize)(cast(PangoAttrSize*) __p); 234 } 235 236 /** 237 * Returns the attribute cast to `PangoAttrString`. 238 * 239 * This is mainly useful for language bindings. 240 * 241 * Returns: The attribute as `PangoAttrString`, 242 * or %NULL if it's not a string attribute 243 * 244 * Since: 1.50 245 */ 246 public PangoAttrString* asString() 247 { 248 return pango_attribute_as_string(pangoAttribute); 249 } 250 251 /** 252 * Make a copy of an attribute. 253 * 254 * Returns: the newly allocated 255 * `PangoAttribute`, which should be freed with 256 * [method@Pango.Attribute.destroy]. 257 */ 258 public PgAttribute copy() 259 { 260 auto __p = pango_attribute_copy(pangoAttribute); 261 262 if(__p is null) 263 { 264 return null; 265 } 266 267 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 268 } 269 270 /** 271 * Destroy a `PangoAttribute` and free all associated memory. 272 */ 273 public void destroy() 274 { 275 pango_attribute_destroy(pangoAttribute); 276 } 277 278 /** 279 * Compare two attributes for equality. 280 * 281 * This compares only the actual value of the two 282 * attributes and not the ranges that the attributes 283 * apply to. 284 * 285 * Params: 286 * attr2 = another `PangoAttribute` 287 * 288 * Returns: %TRUE if the two attributes have the same value 289 */ 290 public bool equal(PgAttribute attr2) 291 { 292 return pango_attribute_equal(pangoAttribute, (attr2 is null) ? null : attr2.getPgAttributeStruct()) != 0; 293 } 294 295 /** 296 * Initializes @attr's klass to @klass, it's start_index to 297 * %PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING and end_index to 298 * %PANGO_ATTR_INDEX_TO_TEXT_END such that the attribute applies 299 * to the entire text by default. 300 * 301 * Params: 302 * klass = a `PangoAttrClass` 303 * 304 * Since: 1.20 305 */ 306 public void init(PangoAttrClass* klass) 307 { 308 pango_attribute_init(pangoAttribute, klass); 309 } 310 311 /** 312 * Create a new background color attribute. 313 * 314 * Params: 315 * red = the red value (ranging from 0 to 65535) 316 * green = the green value 317 * blue = the blue value 318 * 319 * Returns: the newly allocated 320 * `PangoAttribute`, which should be freed with 321 * [method@Pango.Attribute.destroy] 322 */ 323 public static PgAttribute backgroundNew(ushort red, ushort green, ushort blue) 324 { 325 auto __p = pango_attr_background_new(red, green, blue); 326 327 if(__p is null) 328 { 329 return null; 330 } 331 332 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 333 } 334 335 /** 336 * Create a new background alpha attribute. 337 * 338 * Params: 339 * alpha = the alpha value, between 1 and 65536 340 * 341 * Returns: the newly allocated 342 * `PangoAttribute`, which should be freed with 343 * [method@Pango.Attribute.destroy] 344 * 345 * Since: 1.38 346 */ 347 public static PgAttribute backgroundAlphaNew(ushort alpha) 348 { 349 auto __p = pango_attr_background_alpha_new(alpha); 350 351 if(__p is null) 352 { 353 return null; 354 } 355 356 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 357 } 358 359 /** 360 * Create a new font fallback attribute. 361 * 362 * If fallback is disabled, characters will only be 363 * used from the closest matching font on the system. 364 * No fallback will be done to other fonts on the system 365 * that might contain the characters in the text. 366 * 367 * Params: 368 * enableFallback = %TRUE if we should fall back on other fonts 369 * for characters the active font is missing 370 * 371 * Returns: the newly allocated 372 * `PangoAttribute`, which should be freed with 373 * [method@Pango.Attribute.destroy] 374 * 375 * Since: 1.4 376 */ 377 public static PgAttribute fallbackNew(bool enableFallback) 378 { 379 auto __p = pango_attr_fallback_new(enableFallback); 380 381 if(__p is null) 382 { 383 return null; 384 } 385 386 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 387 } 388 389 /** 390 * Create a new font family attribute. 391 * 392 * Params: 393 * family = the family or comma-separated list of families 394 * 395 * Returns: the newly allocated 396 * `PangoAttribute`, which should be freed with 397 * [method@Pango.Attribute.destroy] 398 */ 399 public static PgAttribute familyNew(string family) 400 { 401 auto __p = pango_attr_family_new(Str.toStringz(family)); 402 403 if(__p is null) 404 { 405 return null; 406 } 407 408 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 409 } 410 411 /** 412 * Create a new foreground color attribute. 413 * 414 * Params: 415 * red = the red value (ranging from 0 to 65535) 416 * green = the green value 417 * blue = the blue value 418 * 419 * Returns: the newly allocated 420 * `PangoAttribute`, which should be freed with 421 * [method@Pango.Attribute.destroy] 422 */ 423 public static PgAttribute foregroundNew(ushort red, ushort green, ushort blue) 424 { 425 auto __p = pango_attr_foreground_new(red, green, blue); 426 427 if(__p is null) 428 { 429 return null; 430 } 431 432 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 433 } 434 435 /** 436 * Create a new foreground alpha attribute. 437 * 438 * Params: 439 * alpha = the alpha value, between 1 and 65536 440 * 441 * Returns: the newly allocated 442 * `PangoAttribute`, which should be freed with 443 * [method@Pango.Attribute.destroy] 444 * 445 * Since: 1.38 446 */ 447 public static PgAttribute foregroundAlphaNew(ushort alpha) 448 { 449 auto __p = pango_attr_foreground_alpha_new(alpha); 450 451 if(__p is null) 452 { 453 return null; 454 } 455 456 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 457 } 458 459 /** 460 * Create a new gravity hint attribute. 461 * 462 * Params: 463 * hint = the gravity hint value 464 * 465 * Returns: the newly allocated 466 * `PangoAttribute`, which should be freed with 467 * [method@Pango.Attribute.destroy] 468 * 469 * Since: 1.16 470 */ 471 public static PgAttribute gravityHintNew(PangoGravityHint hint) 472 { 473 auto __p = pango_attr_gravity_hint_new(hint); 474 475 if(__p is null) 476 { 477 return null; 478 } 479 480 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 481 } 482 483 /** 484 * Create a new gravity attribute. 485 * 486 * Params: 487 * gravity = the gravity value; should not be %PANGO_GRAVITY_AUTO 488 * 489 * Returns: the newly allocated 490 * `PangoAttribute`, which should be freed with 491 * [method@Pango.Attribute.destroy] 492 * 493 * Since: 1.16 494 */ 495 public static PgAttribute gravityNew(PangoGravity gravity) 496 { 497 auto __p = pango_attr_gravity_new(gravity); 498 499 if(__p is null) 500 { 501 return null; 502 } 503 504 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 505 } 506 507 /** 508 * Create a new letter-spacing attribute. 509 * 510 * Params: 511 * letterSpacing = amount of extra space to add between 512 * graphemes of the text, in Pango units 513 * 514 * Returns: the newly allocated 515 * `PangoAttribute`, which should be freed with 516 * [method@Pango.Attribute.destroy] 517 * 518 * Since: 1.6 519 */ 520 public static PgAttribute letterSpacingNew(int letterSpacing) 521 { 522 auto __p = pango_attr_letter_spacing_new(letterSpacing); 523 524 if(__p is null) 525 { 526 return null; 527 } 528 529 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 530 } 531 532 /** 533 * Create a new baseline displacement attribute. 534 * 535 * Params: 536 * rise = the amount that the text should be displaced vertically, 537 * in Pango units. Positive values displace the text upwards. 538 * 539 * Returns: the newly allocated 540 * `PangoAttribute`, which should be freed with 541 * [method@Pango.Attribute.destroy] 542 */ 543 public static PgAttribute riseNew(int rise) 544 { 545 auto __p = pango_attr_rise_new(rise); 546 547 if(__p is null) 548 { 549 return null; 550 } 551 552 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 553 } 554 555 /** 556 * Create a new font size scale attribute. 557 * 558 * The base font for the affected text will have 559 * its size multiplied by @scale_factor. 560 * 561 * Params: 562 * scaleFactor = factor to scale the font 563 * 564 * Returns: the newly allocated 565 * `PangoAttribute`, which should be freed with 566 * [method@Pango.Attribute.destroy] 567 */ 568 public static PgAttribute scaleNew(double scaleFactor) 569 { 570 auto __p = pango_attr_scale_new(scaleFactor); 571 572 if(__p is null) 573 { 574 return null; 575 } 576 577 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 578 } 579 580 /** 581 * Create a new font stretch attribute. 582 * 583 * Params: 584 * stretch = the stretch 585 * 586 * Returns: the newly allocated 587 * `PangoAttribute`, which should be freed with 588 * [method@Pango.Attribute.destroy] 589 */ 590 public static PgAttribute stretchNew(PangoStretch stretch) 591 { 592 auto __p = pango_attr_stretch_new(stretch); 593 594 if(__p is null) 595 { 596 return null; 597 } 598 599 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 600 } 601 602 /** 603 * Create a new strikethrough color attribute. 604 * 605 * This attribute modifies the color of strikethrough lines. 606 * If not set, strikethrough lines will use the foreground color. 607 * 608 * Params: 609 * red = the red value (ranging from 0 to 65535) 610 * green = the green value 611 * blue = the blue value 612 * 613 * Returns: the newly allocated 614 * `PangoAttribute`, which should be freed with 615 * [method@Pango.Attribute.destroy] 616 * 617 * Since: 1.8 618 */ 619 public static PgAttribute strikethroughColorNew(ushort red, ushort green, ushort blue) 620 { 621 auto __p = pango_attr_strikethrough_color_new(red, green, blue); 622 623 if(__p is null) 624 { 625 return null; 626 } 627 628 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 629 } 630 631 /** 632 * Create a new strike-through attribute. 633 * 634 * Params: 635 * strikethrough = %TRUE if the text should be struck-through 636 * 637 * Returns: the newly allocated 638 * `PangoAttribute`, which should be freed with 639 * [method@Pango.Attribute.destroy] 640 */ 641 public static PgAttribute strikethroughNew(bool strikethrough) 642 { 643 auto __p = pango_attr_strikethrough_new(strikethrough); 644 645 if(__p is null) 646 { 647 return null; 648 } 649 650 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 651 } 652 653 /** 654 * Create a new font slant style attribute. 655 * 656 * Params: 657 * style = the slant style 658 * 659 * Returns: the newly allocated 660 * `PangoAttribute`, which should be freed with 661 * [method@Pango.Attribute.destroy] 662 */ 663 public static PgAttribute styleNew(PangoStyle style) 664 { 665 auto __p = pango_attr_style_new(style); 666 667 if(__p is null) 668 { 669 return null; 670 } 671 672 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 673 } 674 675 /** 676 * Fetches the attribute type name. 677 * 678 * The attribute type name is the string passed in 679 * when registering the type using 680 * [func@Pango.AttrType.register]. 681 * 682 * The returned value is an interned string (see 683 * g_intern_string() for what that means) that should 684 * not be modified or freed. 685 * 686 * Params: 687 * type = an attribute type ID to fetch the name for 688 * 689 * Returns: the type ID name (which 690 * may be %NULL), or %NULL if @type is a built-in Pango 691 * attribute type or invalid. 692 * 693 * Since: 1.22 694 */ 695 public static string typeGetName(PangoAttrType type) 696 { 697 return Str.toString(pango_attr_type_get_name(type)); 698 } 699 700 /** 701 * Allocate a new attribute type ID. 702 * 703 * The attribute type name can be accessed later 704 * by using [func@Pango.AttrType.get_name]. 705 * 706 * Params: 707 * name = an identifier for the type 708 * 709 * Returns: the new type ID. 710 */ 711 public static PangoAttrType typeRegister(string name) 712 { 713 return pango_attr_type_register(Str.toStringz(name)); 714 } 715 716 /** 717 * Create a new underline color attribute. 718 * 719 * This attribute modifies the color of underlines. 720 * If not set, underlines will use the foreground color. 721 * 722 * Params: 723 * red = the red value (ranging from 0 to 65535) 724 * green = the green value 725 * blue = the blue value 726 * 727 * Returns: the newly allocated 728 * `PangoAttribute`, which should be freed with 729 * [method@Pango.Attribute.destroy] 730 * 731 * Since: 1.8 732 */ 733 public static PgAttribute underlineColorNew(ushort red, ushort green, ushort blue) 734 { 735 auto __p = pango_attr_underline_color_new(red, green, blue); 736 737 if(__p is null) 738 { 739 return null; 740 } 741 742 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 743 } 744 745 /** 746 * Create a new underline-style attribute. 747 * 748 * Params: 749 * underline = the underline style 750 * 751 * Returns: the newly allocated 752 * `PangoAttribute`, which should be freed with 753 * [method@Pango.Attribute.destroy] 754 */ 755 public static PgAttribute underlineNew(PangoUnderline underline) 756 { 757 auto __p = pango_attr_underline_new(underline); 758 759 if(__p is null) 760 { 761 return null; 762 } 763 764 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 765 } 766 767 /** 768 * Create a new font variant attribute (normal or small caps). 769 * 770 * Params: 771 * variant = the variant 772 * 773 * Returns: the newly allocated `PangoAttribute`, 774 * which should be freed with [method@Pango.Attribute.destroy]. 775 */ 776 public static PgAttribute variantNew(PangoVariant variant) 777 { 778 auto __p = pango_attr_variant_new(variant); 779 780 if(__p is null) 781 { 782 return null; 783 } 784 785 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 786 } 787 788 /** 789 * Create a new font weight attribute. 790 * 791 * Params: 792 * weight = the weight 793 * 794 * Returns: the newly allocated 795 * `PangoAttribute`, which should be freed with 796 * [method@Pango.Attribute.destroy] 797 */ 798 public static PgAttribute weightNew(PangoWeight weight) 799 { 800 auto __p = pango_attr_weight_new(weight); 801 802 if(__p is null) 803 { 804 return null; 805 } 806 807 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) __p, true); 808 } 809 810 /** 811 * Finishes parsing markup. 812 * 813 * After feeding a Pango markup parser some data with [method@GLib.MarkupParseContext.parse], 814 * use this function to get the list of attributes and text out of the 815 * markup. This function will not free @context, use [method@GLib.MarkupParseContext.free] 816 * to do so. 817 * 818 * Params: 819 * context = A valid parse context that was returned from [func@markup_parser_new] 820 * attrList = address of return location for a `PangoAttrList` 821 * text = address of return location for text with tags stripped 822 * accelChar = address of return location for accelerator char 823 * 824 * Returns: %FALSE if @error is set, otherwise %TRUE 825 * 826 * Since: 1.31.0 827 * 828 * Throws: GException on failure. 829 */ 830 public static bool markupParserFinish(SimpleXML context, out PgAttributeList attrList, out string text, out dchar accelChar) 831 { 832 PangoAttrList* outattrList = null; 833 char* outtext = null; 834 GError* err = null; 835 836 auto __p = pango_markup_parser_finish((context is null) ? null : context.getSimpleXMLStruct(), &outattrList, &outtext, &accelChar, &err) != 0; 837 838 if (err !is null) 839 { 840 throw new GException( new ErrorG(err) ); 841 } 842 843 attrList = ObjectG.getDObject!(PgAttributeList)(outattrList); 844 text = Str.toString(outtext); 845 846 return __p; 847 } 848 849 /** 850 * Incrementally parses marked-up text to create a plain-text string 851 * and an attribute list. 852 * 853 * See the [Pango Markup](pango_markup.html) docs for details about the 854 * supported markup. 855 * 856 * If @accel_marker is nonzero, the given character will mark the 857 * character following it as an accelerator. For example, @accel_marker 858 * might be an ampersand or underscore. All characters marked 859 * as an accelerator will receive a %PANGO_UNDERLINE_LOW attribute, 860 * and the first character so marked will be returned in @accel_char, 861 * when calling [func@markup_parser_finish]. Two @accel_marker characters 862 * following each other produce a single literal @accel_marker character. 863 * 864 * To feed markup to the parser, use [method@GLib.MarkupParseContext.parse] 865 * on the returned [struct@GLib.MarkupParseContext]. When done with feeding markup 866 * to the parser, use [func@markup_parser_finish] to get the data out 867 * of it, and then use [method@GLib.MarkupParseContext.free] to free it. 868 * 869 * This function is designed for applications that read Pango markup 870 * from streams. To simply parse a string containing Pango markup, 871 * the [func@Pango.parse_markup] API is recommended instead. 872 * 873 * Params: 874 * accelMarker = character that precedes an accelerator, or 0 for none 875 * 876 * Returns: a `GMarkupParseContext` that should be 877 * destroyed with [method@GLib.MarkupParseContext.free]. 878 * 879 * Since: 1.31.0 880 */ 881 public static SimpleXML markupParserNew(dchar accelMarker) 882 { 883 auto __p = pango_markup_parser_new(accelMarker); 884 885 if(__p is null) 886 { 887 return null; 888 } 889 890 return new SimpleXML(cast(GMarkupParseContext*) __p); 891 } 892 893 /** 894 * Parses marked-up text to create a plain-text string and an attribute list. 895 * 896 * See the [Pango Markup](pango_markup.html) docs for details about the 897 * supported markup. 898 * 899 * If @accel_marker is nonzero, the given character will mark the 900 * character following it as an accelerator. For example, @accel_marker 901 * might be an ampersand or underscore. All characters marked 902 * as an accelerator will receive a %PANGO_UNDERLINE_LOW attribute, 903 * and the first character so marked will be returned in @accel_char. 904 * Two @accel_marker characters following each other produce a single 905 * literal @accel_marker character. 906 * 907 * To parse a stream of pango markup incrementally, use [func@markup_parser_new]. 908 * 909 * If any error happens, none of the output arguments are touched except 910 * for @error. 911 * 912 * Params: 913 * markupText = markup to parse (see the [Pango Markup](pango_markup.html) docs) 914 * length = length of @markup_text, or -1 if nul-terminated 915 * accelMarker = character that precedes an accelerator, or 0 for none 916 * attrList = address of return location for a `PangoAttrList` 917 * text = address of return location for text with tags stripped 918 * accelChar = address of return location for accelerator char 919 * 920 * Returns: %FALSE if @error is set, otherwise %TRUE 921 * 922 * Throws: GException on failure. 923 */ 924 public static bool parseMarkup(string markupText, int length, dchar accelMarker, out PgAttributeList attrList, out string text, out dchar accelChar) 925 { 926 PangoAttrList* outattrList = null; 927 char* outtext = null; 928 GError* err = null; 929 930 auto __p = pango_parse_markup(Str.toStringz(markupText), length, accelMarker, &outattrList, &outtext, &accelChar, &err) != 0; 931 932 if (err !is null) 933 { 934 throw new GException( new ErrorG(err) ); 935 } 936 937 attrList = ObjectG.getDObject!(PgAttributeList)(outattrList); 938 text = Str.toString(outtext); 939 940 return __p; 941 } 942 }